let username = document.querySelector('.username')
let password = document.querySelector('.password')
let err = document.querySelector('button')
let form = document.querySelector('form')

form.addEventListener('submit',e =>{
    e = e || window.event
    try{e.preventDefault()} catch(err){e.returnValue = false}

    let name = username.value.trim()
    let pw = password.value.trim()

    if(!name || !pw)return alert('内容不可为空')

    name1 = window.localStorage.getItem('name')
    pw1 = window.localStorage.getItem('pw')
    if(name!=name1)return window.location.href=confirm('用户名不存在')
    if(name!=name1||pw1!=pw1)return alert('密码错误')
    alert('登陆成功')
    window.localStorage.setItem('token','1')
    window.location.href='../views/index.html'
    



    
})